package net.qiyuesuo.pojo;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;


/**
 * 文件信息实体类
 *
 */
public class FileMeta {
	
	//文件名
	private String uuid;
	//文件大小
	private Long size;
	//创建时间
	private Date createTime;
	
	public FileMeta() {
	}
	
	public FileMeta(String uuid,Long size,Date createTime) {
		this.uuid = uuid;
		this.size = size;
		this.createTime = createTime;
	}
	
	/**
	 * 将json串转为对象
	 * @param json
	 */
	public FileMeta(String json) {
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String [] strs = json.split(",");
		try {
			this.uuid = strs[0].substring(5, strs[0].length());
			this.size = Long.valueOf(strs[1].substring(5,strs[1].length()));
			this.createTime = format.parse(strs[2].substring(11,strs[2].length()));
		} catch (ParseException e) {
			e.printStackTrace();
		}
	}
	
	public String getUuid() {
		return uuid;
	}

	public void setUuid(String uuid) {
		this.uuid = uuid;
	}

	public Long getSize() {
		return size;
	}
	public void setSize(Long size) {
		this.size = size;
	}
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	
	public String toJson() {
		String json ="[{\"uuid\":\""+this.uuid+"\",\"size\":"+this.size+",\"createTime\":\""+this.createTime+"\"}]";
		return json;
	}
	
}
